package com.yiwyn.controller;

import com.yiwyn.domain.BookSearchDTO;
import com.yiwyn.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class BookController {

    @Autowired
    private BookService bookService;

    @GetMapping("/save")
    public String save(String name) {
        bookService.save(name);
        return "success";
    }

    @GetMapping("/search")
    public List<BookSearchDTO> search(String name) {
        List<BookSearchDTO> search = bookService.search(name);
        return search;
    }

    @GetMapping("/deleteAll")
    public String deleteAll() {
        bookService.deleteAll();
        return "success";
    }
}
